<include file="Public/head"/>
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css"/>
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<style type="text/css">
    .select_model {
        -moz-appearance: none;
        background: rgba(0, 0, 0, 0) url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat scroll 115px 5px;
        border: 1px solid #d7d7d7;
        float: left;
        height: 26px;
        line-height: 26px;
        margin-right: 8px;
        margin-left: 10px;
        text-indent: 2px;
        width: 136px;
    }

    .select2-container .select2-choice {
        background: #fff url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat scroll 132px 5px;
        width: 140px;
    }
</style>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu="clcwht.clzh"/>
    <div class="mianR">
        <div class="yuyue">
            <ul>
                <li onclick="get_list(1);" class="yuCurrent">待置换</li>
                <li onclick="get_list(2);">置换成功</li>
                <li onclick="get_list(3);">置换失败</li>
            </ul>
        </div>
        <div class="yuList">
            <div class="yuSuo clearfix" style="float:left;">
                <input id="status" name="status" type="hidden" value="{$params.status|default=1}"/>
                <input type="text" id="start_time" name="start_time" value="" readonly placeholder="注册开始时间"
                       style="margin-left: 10px;"/><em></em>
                <input type="text" id="end_time" name="end_time" value="" readonly placeholder="注册结束时间"
                       style="margin-right: 10px;"/>
                <select name="location_area" id="location_area" class="select_model">
                    <if condition="count($city_list) gt 1">
                        <option value="0">请选择原车所在地</option>
                    </if>
                    <volist name="city_list" id="city">
                        <option value="{$city.city_code}">{$city.city_name}</option>
                    </volist>
                </select>

                <input type="button" id="search" value="搜索" class="suoSou">
            </div>

            <div class="listBox" id="listBox">

            </div>
        </div>
        <div class="clear"></div>
    </div>
</div>

<script type="text/javascript">
    $("#start_time").ymdateplugin({
        changeMonth: true,
        changeYear: true
    });
    $("#end_time").ymdateplugin({
        changeMonth: true,
        changeYear: true
    });

    function get_page(p) {
        var status = $("#status").val();
        var url = get_url();
        url += "&p=" + p;
        $.get("/ChangeCar/changeCarList?status=" + status, encodeURI(url), function (data) {
            $("#listBox").html(data);
        }, "html");
    }
    get_list(1);
    function get_list(status) {
        change_tabs(status);
        $("#status").val(status);
        var url = get_url();
        $.get("/ChangeCar/changeCarList?status=" + status, url, function (data) {
            $("#listBox").html(data);
        }, "html");
    }
    function get_url() {
        var url = "";
        var location_area = $("#location_area").val();
        var start_time = $("#start_time").val();
        var end_time = $("#end_time").val();
        if (location_area > 0) {
            url += '&location_area=' + location_area;
        }
        if (start_time) {
            url += '&start_time=' + start_time;
        }
        if (end_time) {
            url += '&end_time=' + end_time;
        }
        return url;
    }

    $('#search').on('click', function () {
        var status = $("#status").val();
        get_list(status);
    });

    function change_tabs(status) {
        if (status == 1) {
            var start_placeholder = '请选择提交时间';
            var end_placeholder = '请选择提交时间';
        } else if (status == 2 || status == 3) {
            var start_placeholder = '请选择处理时间';
            var end_placeholder = '请选择处理时间';
        }
        $("#start_time").attr('placeholder', start_placeholder);
        $("#end_time").attr('placeholder', end_placeholder);
        if ($("#status").val() != status) {
            clear_form_params();
        }
    }
    function clear_form_params() {
        $(':input').not(':button, :submit, :reset, :hidden, select').val('');
        if ($("#location_area option").length > 1) {
            $("#location_area").val(0);
        }
    }
</script>
<include file="Public/foot"/>